package com.example.crm.config;

import com.example.crm.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    public LoginInterceptor getLoginInterceptor(){
        return new LoginInterceptor();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器进容器
        registry.addInterceptor(getLoginInterceptor())
                .addPathPatterns("/**")//拦截的请求,所有请求，静态资源也拦截
                .excludePathPatterns("/", "/login");//放行的请求

    }



}
